changed gtk_item_factory_dump_items() and gtk_item_factory_dump_rc()
authorTim Janik <timj@gtk.org>
Tue, 3 Apr 2001 13:18:00 +0000 (13:18 +0000)
committerTim Janik <timj@src.gnome.org>
Tue, 3 Apr 2001 13:18:00 +0000 (13:18 +0000)
Tue Apr  3 13:52:57 2001  Tim Janik  <timj@gtk.org>

        * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items()
        and gtk_item_factory_dump_rc() GtkPatternSpec argument to
        GPatternSpec. this is actually unlikely to cause breakage in
        third-party apps since except for gle, pretty much ever caller
        passes NULL here.

        * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API.

        * *.c: use g_pattern_*() API.

        * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates.

        * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled
        directions aren't passed in.

        * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion
        functionality to be usable from gtkstyle.c as well, give precedence
        for conversion to user-supplied parsers.
        s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/;

        * gtk/gtkstyle.c (_gtk_style_peek_property_value): use
        _gtk_settings_parse_convert() for rcporperty value conversion.

21 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/Changes-2.0.txt
docs/reference/gtk/tmpl/gtk-unused.sgml
docs/reference/gtk/tmpl/gtkbindings.sgml
gtk/gtkbindings.c
gtk/gtkbindings.h
gtk/gtkitemfactory.c
gtk/gtkitemfactory.h
gtk/gtkrc.c
gtk/gtksettings.c
gtk/gtksettings.h
gtk/gtkstyle.c
gtk/gtkwidget.c
gtk/testgtkrc
tests/testgtkrc

index 62342938793983f3941b2ef2ffa225e495dd105c..37c281cee46c455a6577ff218b0ca82fea20ea03 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+Tue Apr  3 13:52:57 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items()
+       and gtk_item_factory_dump_rc() GtkPatternSpec argument to
+       GPatternSpec. this is actually unlikely to cause breakage in
+       third-party apps since except for gle, pretty much ever caller
+       passes NULL here.
+
+       * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API.
+
+       * *.c: use g_pattern_*() API.
+
+       * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates.
+
+       * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled
+       directions aren't passed in.
+
+       * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion
+       functionality to be usable from gtkstyle.c as well, give precedence
+       for conversion to user-supplied parsers.
+       s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/;
+
+       * gtk/gtkstyle.c (_gtk_style_peek_property_value): use
+       _gtk_settings_parse_convert() for rcporperty value conversion.
+
 2001-04-03  Alexander Larsson  <alexl@redhat.com>
 
        * gdk/linux-fb/gdkevents-fb.c:
index 62342938793983f3941b2ef2ffa225e495dd105c..37c281cee46c455a6577ff218b0ca82fea20ea03 100644 (file)
@@ -1,3 +1,28 @@
+Tue Apr  3 13:52:57 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items()
+       and gtk_item_factory_dump_rc() GtkPatternSpec argument to
+       GPatternSpec. this is actually unlikely to cause breakage in
+       third-party apps since except for gle, pretty much ever caller
+       passes NULL here.
+
+       * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API.
+
+       * *.c: use g_pattern_*() API.
+
+       * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates.
+
+       * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled
+       directions aren't passed in.
+
+       * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion
+       functionality to be usable from gtkstyle.c as well, give precedence
+       for conversion to user-supplied parsers.
+       s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/;
+
+       * gtk/gtkstyle.c (_gtk_style_peek_property_value): use
+       _gtk_settings_parse_convert() for rcporperty value conversion.
+
 2001-04-03  Alexander Larsson  <alexl@redhat.com>
 
        * gdk/linux-fb/gdkevents-fb.c:
index 62342938793983f3941b2ef2ffa225e495dd105c..37c281cee46c455a6577ff218b0ca82fea20ea03 100644 (file)
@@ -1,3 +1,28 @@
+Tue Apr  3 13:52:57 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items()
+       and gtk_item_factory_dump_rc() GtkPatternSpec argument to
+       GPatternSpec. this is actually unlikely to cause breakage in
+       third-party apps since except for gle, pretty much ever caller
+       passes NULL here.
+
+       * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API.
+
+       * *.c: use g_pattern_*() API.
+
+       * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates.
+
+       * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled
+       directions aren't passed in.
+
+       * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion
+       functionality to be usable from gtkstyle.c as well, give precedence
+       for conversion to user-supplied parsers.
+       s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/;
+
+       * gtk/gtkstyle.c (_gtk_style_peek_property_value): use
+       _gtk_settings_parse_convert() for rcporperty value conversion.
+
 2001-04-03  Alexander Larsson  <alexl@redhat.com>
 
        * gdk/linux-fb/gdkevents-fb.c:
index 62342938793983f3941b2ef2ffa225e495dd105c..37c281cee46c455a6577ff218b0ca82fea20ea03 100644 (file)
@@ -1,3 +1,28 @@
+Tue Apr  3 13:52:57 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items()
+       and gtk_item_factory_dump_rc() GtkPatternSpec argument to
+       GPatternSpec. this is actually unlikely to cause breakage in
+       third-party apps since except for gle, pretty much ever caller
+       passes NULL here.
+
+       * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API.
+
+       * *.c: use g_pattern_*() API.
+
+       * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates.
+
+       * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled
+       directions aren't passed in.
+
+       * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion
+       functionality to be usable from gtkstyle.c as well, give precedence
+       for conversion to user-supplied parsers.
+       s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/;
+
+       * gtk/gtkstyle.c (_gtk_style_peek_property_value): use
+       _gtk_settings_parse_convert() for rcporperty value conversion.
+
 2001-04-03  Alexander Larsson  <alexl@redhat.com>
 
        * gdk/linux-fb/gdkevents-fb.c:
index 62342938793983f3941b2ef2ffa225e495dd105c..37c281cee46c455a6577ff218b0ca82fea20ea03 100644 (file)
@@ -1,3 +1,28 @@
+Tue Apr  3 13:52:57 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items()
+       and gtk_item_factory_dump_rc() GtkPatternSpec argument to
+       GPatternSpec. this is actually unlikely to cause breakage in
+       third-party apps since except for gle, pretty much ever caller
+       passes NULL here.
+
+       * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API.
+
+       * *.c: use g_pattern_*() API.
+
+       * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates.
+
+       * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled
+       directions aren't passed in.
+
+       * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion
+       functionality to be usable from gtkstyle.c as well, give precedence
+       for conversion to user-supplied parsers.
+       s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/;
+
+       * gtk/gtkstyle.c (_gtk_style_peek_property_value): use
+       _gtk_settings_parse_convert() for rcporperty value conversion.
+
 2001-04-03  Alexander Larsson  <alexl@redhat.com>
 
        * gdk/linux-fb/gdkevents-fb.c:
index 62342938793983f3941b2ef2ffa225e495dd105c..37c281cee46c455a6577ff218b0ca82fea20ea03 100644 (file)
@@ -1,3 +1,28 @@
+Tue Apr  3 13:52:57 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items()
+       and gtk_item_factory_dump_rc() GtkPatternSpec argument to
+       GPatternSpec. this is actually unlikely to cause breakage in
+       third-party apps since except for gle, pretty much ever caller
+       passes NULL here.
+
+       * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API.
+
+       * *.c: use g_pattern_*() API.
+
+       * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates.
+
+       * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled
+       directions aren't passed in.
+
+       * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion
+       functionality to be usable from gtkstyle.c as well, give precedence
+       for conversion to user-supplied parsers.
+       s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/;
+
+       * gtk/gtkstyle.c (_gtk_style_peek_property_value): use
+       _gtk_settings_parse_convert() for rcporperty value conversion.
+
 2001-04-03  Alexander Larsson  <alexl@redhat.com>
 
        * gdk/linux-fb/gdkevents-fb.c:
index 62342938793983f3941b2ef2ffa225e495dd105c..37c281cee46c455a6577ff218b0ca82fea20ea03 100644 (file)
@@ -1,3 +1,28 @@
+Tue Apr  3 13:52:57 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkitemfactory.[hc]: changed gtk_item_factory_dump_items()
+       and gtk_item_factory_dump_rc() GtkPatternSpec argument to
+       GPatternSpec. this is actually unlikely to cause breakage in
+       third-party apps since except for gle, pretty much ever caller
+       passes NULL here.
+
+       * gtk/gtkbindings.[hc]: removed gtk_pattern_*() API.
+
+       * *.c: use g_pattern_*() API.
+
+       * docs/Changes-2.0.txt: GtkPatternSpec->GPatternSpec updates.
+
+       * gtk/gtkstyle.c (gtk_default_draw_resize_grip): assert unhandled
+       directions aren't passed in.
+
+       * gtk/gtksettings.[hc] (_gtk_settings_parse_convert): export conversion
+       functionality to be usable from gtkstyle.c as well, give precedence
+       for conversion to user-supplied parsers.
+       s/_gtk_rc_property_parser_for_type/_gtk_rc_property_parser_from_type/;
+
+       * gtk/gtkstyle.c (_gtk_style_peek_property_value): use
+       _gtk_settings_parse_convert() for rcporperty value conversion.
+
 2001-04-03  Alexander Larsson  <alexl@redhat.com>
 
        * gdk/linux-fb/gdkevents-fb.c:
index f834f605c4cecf34cd8849487256159c67c6df8f..304c968e06289f3861413d6b4478e87b9a523893 100644 (file)
@@ -32,6 +32,10 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
 * gtk_widget_shape_combine_mask() now keeps a reference count on the 
   mask pixmap that is passed in.
 
+* the GtkPatternSpec has been moved to glib as GPatternSpec, the pattern
+  arguments to gtk_item_factory_dump_items() and gtk_item_factory_dump_rc()
+  have thusly been changed to take a GPatternSpec instead of GtkPatternSpec.
+  
 * Type system changes:
   - GTK_TYPE_OBJECT is not a fundamental type anymore. Type checks of the
     style (GTK_FUNDAMENTAL_TYPE (some_type) == GTK_TYPE_OBJECT)
index f4cce16521b7b30c8fd28438296a54c18a36e439..9b136f005cbd3a3f948f988a159b6abebb843cdf 100644 (file)
@@ -604,6 +604,18 @@ after other user handlers and the default handler.
 </para>
 
 
+<!-- ##### STRUCT GtkPatternSpec ##### -->
+<para>
+
+</para>
+
+@match_type: 
+@pattern_length: 
+@pattern: 
+@pattern_reversed: 
+@user_data: 
+@seq_id: 
+
 <!-- ##### ENUM GtkPrivateFlags ##### -->
 <para>
 
@@ -1172,6 +1184,50 @@ Set the the handle size to @size x @size pixels.
 @paned: a paned widget
 @size: the size in pixels
 
+<!-- ##### FUNCTION gtk_pattern_match ##### -->
+<para>
+
+</para>
+
+@pspec: 
+@string_length: 
+@string: 
+@string_reversed: 
+@Returns: 
+
+<!-- ##### FUNCTION gtk_pattern_match_simple ##### -->
+<para>
+
+</para>
+
+@pattern: 
+@string: 
+@Returns: 
+
+<!-- ##### FUNCTION gtk_pattern_match_string ##### -->
+<para>
+
+</para>
+
+@pspec: 
+@string: 
+@Returns: 
+
+<!-- ##### FUNCTION gtk_pattern_spec_free_segs ##### -->
+<para>
+
+</para>
+
+@pspec: 
+
+<!-- ##### FUNCTION gtk_pattern_spec_init ##### -->
+<para>
+
+</para>
+
+@pspec: 
+@pattern: 
+
 <!-- ##### FUNCTION gtk_rc_init ##### -->
 <para>
 Internal function.
index a5c84f097de70730fbde74c890b757610300eb3f..e790765b32b3f8d705a1a5c4759e3360037dcf30 100644 (file)
@@ -14,67 +14,6 @@ Bindings
 
 </para>
 
-<!-- ##### STRUCT GtkPatternSpec ##### -->
-<para>
-
-</para>
-
-@match_type: 
-@pattern_length: 
-@pattern: 
-@pattern_reversed: 
-@user_data: 
-@seq_id: 
-
-<!-- ##### FUNCTION gtk_pattern_spec_init ##### -->
-<para>
-
-</para>
-
-@pspec: 
-@pattern: 
-
-
-<!-- ##### FUNCTION gtk_pattern_spec_free_segs ##### -->
-<para>
-
-</para>
-
-@pspec: 
-
-
-<!-- ##### FUNCTION gtk_pattern_match ##### -->
-<para>
-
-</para>
-
-@pspec: 
-@string_length: 
-@string: 
-@string_reversed: 
-@Returns: 
-
-
-<!-- ##### FUNCTION gtk_pattern_match_string ##### -->
-<para>
-
-</para>
-
-@pspec: 
-@string: 
-@Returns: 
-
-
-<!-- ##### FUNCTION gtk_pattern_match_simple ##### -->
-<para>
-
-</para>
-
-@pattern: 
-@string: 
-@Returns: 
-
-
 <!-- ##### STRUCT GtkBindingSet ##### -->
 <para>
 
index 4004622f7028def0e54d3439b9d9e52d317b13eb..41e65a15a2c7be4d7b5e9cdd538bb39333a272e8 100644 (file)
 #define        BINDING_MOD_MASK()      (gtk_accelerator_get_default_mod_mask () | GDK_RELEASE_MASK)
 
 
+/* --- structures --- */
+typedef struct {
+  GPatternSpec *pspec;
+  gpointer user_data;
+  guint seq_id;
+} PatternSpec;
+
+
 /* --- variables --- */
 static GHashTable      *binding_entry_hash_table = NULL;
 static GSList          *binding_set_list = NULL;
@@ -719,7 +727,7 @@ gtk_binding_set_add_path (GtkBindingSet          *binding_set,
                          const gchar        *path_pattern,
                          GtkPathPriorityType priority)
 {
-  GtkPatternSpec *pspec;
+  PatternSpec *pspec;
   GSList **slist_p, *slist;
   static guint seq_id = 0;
   
@@ -745,8 +753,8 @@ gtk_binding_set_add_path (GtkBindingSet          *binding_set,
       break;
     }
   
-  pspec = g_new (GtkPatternSpec, 1);
-  gtk_pattern_spec_init (pspec, path_pattern);
+  pspec = g_new (PatternSpec, 1);
+  pspec->pspec = g_pattern_spec_new (path_pattern);
   pspec->seq_id = seq_id++ & 0x0fffffff;
   pspec->seq_id |= priority << 28;
   pspec->user_data = binding_set;
@@ -754,15 +762,15 @@ gtk_binding_set_add_path (GtkBindingSet        *binding_set,
   slist = *slist_p;
   while (slist)
     {
-      GtkPatternSpec *tmp_pspec;
+      PatternSpec *tmp_pspec;
       
       tmp_pspec = slist->data;
       slist = slist->next;
       
-      if (tmp_pspec->pattern_length == pspec->pattern_length &&
-         g_str_equal (tmp_pspec->pattern_reversed, pspec->pattern_reversed))
+      if (tmp_pspec->pspec->pattern_length == pspec->pspec->pattern_length &&
+         g_str_equal (tmp_pspec->pspec->pattern_reversed, pspec->pspec->pattern_reversed))
        {
-         gtk_pattern_spec_free_segs (pspec);
+         g_pattern_spec_free (pspec->pspec);
          g_free (pspec);
          pspec = NULL;
          break;
@@ -783,10 +791,10 @@ binding_match_activate (GSList          *pspec_list,
 
   for (slist = pspec_list; slist; slist = slist->next)
     {
-      GtkPatternSpec *pspec;
+      PatternSpec *pspec;
 
       pspec = slist->data;
-      if (gtk_pattern_match (pspec, path_length, path, path_reversed))
+      if (g_pattern_match (pspec->pspec, path_length, path, path_reversed))
        {
          GtkBindingSet *binding_set;
 
@@ -805,8 +813,8 @@ static gint
 gtk_binding_pattern_compare (gconstpointer new_pattern,
                             gconstpointer existing_pattern)
 {
-  register const GtkPatternSpec *np  = new_pattern;
-  register const GtkPatternSpec *ep  = existing_pattern;
+  register const PatternSpec *np  = new_pattern;
+  register const PatternSpec *ep  = existing_pattern;
 
   /* walk the list as long as the existing patterns have
    * higher priorities.
@@ -845,7 +853,7 @@ gtk_binding_entries_sort_patterns (GtkBindingEntry    *entries,
 
       for (; slist; slist = slist->next)
        {
-         GtkPatternSpec *pspec;
+         PatternSpec *pspec;
 
          pspec = slist->data;
          patterns = g_slist_insert_sorted (patterns, pspec, gtk_binding_pattern_compare);
@@ -938,255 +946,6 @@ gtk_bindings_activate (GtkObject      *object,
   return handled;
 }
 
-
-
-
-
-
-
-
-
-
-/* Patterns
- */
-
-static inline gboolean
-gtk_pattern_ph_match (const gchar   *match_pattern,
-                     const gchar   *match_string)
-{
-  register const gchar *pattern, *string;
-  register gchar ch;
-  
-  pattern = match_pattern;
-  string = match_string;
-  
-  ch = *pattern;
-  pattern++;
-  while (ch)
-    {
-      switch (ch)
-       {
-       case  '?':
-         if (!*string)
-           return FALSE;
-         string++;
-         break;
-         
-       case  '*':
-         do
-           {
-             ch = *pattern;
-             pattern++;
-             if (ch == '?')
-               {
-                 if (!*string)
-                   return FALSE;
-                 string++;
-               }
-           }
-         while (ch == '*' || ch == '?');
-         if (!ch)
-           return TRUE;
-         do
-           {
-             while (ch != *string)
-               {
-                 if (!*string)
-                   return FALSE;
-                 string++;
-               }
-             string++;
-             if (gtk_pattern_ph_match (pattern, string))
-               return TRUE;
-           }
-         while (*string);
-         break;
-         
-       default:
-         if (ch == *string)
-           string++;
-         else
-           return FALSE;
-         break;
-       }
-      
-      ch = *pattern;
-      pattern++;
-    }
-  
-  return *string == 0;
-}
-
-gboolean
-gtk_pattern_match (GtkPatternSpec      *pspec,
-                  guint                 string_length,
-                  const gchar          *string,
-                  const gchar          *string_reversed)
-{
-  g_return_val_if_fail (pspec != NULL, FALSE);
-  g_return_val_if_fail (string != NULL, FALSE);
-  g_return_val_if_fail (string_reversed != NULL, FALSE);
-  
-  switch (pspec->match_type)
-    {
-    case  GTK_MATCH_ALL:
-      return gtk_pattern_ph_match (pspec->pattern, string);
-      
-    case  GTK_MATCH_ALL_TAIL:
-      return gtk_pattern_ph_match (pspec->pattern_reversed, string_reversed);
-      
-    case  GTK_MATCH_HEAD:
-      if (pspec->pattern_length > string_length)
-       return FALSE;
-      else if (pspec->pattern_length == string_length)
-       return strcmp (pspec->pattern, string) == 0;
-      else if (pspec->pattern_length)
-       return strncmp (pspec->pattern, string, pspec->pattern_length) == 0;
-      else
-       return TRUE;
-      
-    case  GTK_MATCH_TAIL:
-      if (pspec->pattern_length > string_length)
-       return FALSE;
-      else if (pspec->pattern_length == string_length)
-       return strcmp (pspec->pattern_reversed, string_reversed) == 0;
-      else if (pspec->pattern_length)
-       return strncmp (pspec->pattern_reversed,
-                       string_reversed,
-                       pspec->pattern_length) == 0;
-      else
-       return TRUE;
-      
-    case  GTK_MATCH_EXACT:
-      if (pspec->pattern_length != string_length)
-       return FALSE;
-      else
-       return strcmp (pspec->pattern_reversed, string_reversed) == 0;
-      
-    default:
-      g_return_val_if_fail (pspec->match_type < GTK_MATCH_LAST, FALSE);
-      return FALSE;
-    }
-}
-
-void
-gtk_pattern_spec_init (GtkPatternSpec        *pspec,
-                      const gchar            *pattern)
-{
-  gchar *p;
-  
-  g_return_if_fail (pspec != NULL);
-  
-  pspec->match_type = GTK_MATCH_ALL;
-  pspec->seq_id = 0;
-  pspec->user_data = NULL;
-  
-  if (!pattern)
-    pattern = "";
-  
-  pspec->pattern = g_strdup (pattern);
-  pspec->pattern_length = strlen (pspec->pattern);
-  pspec->pattern_reversed = g_strdup (pspec->pattern);
-  g_strreverse (pspec->pattern_reversed);
-  if (pspec->pattern_reversed[0] != '*')
-    pspec->match_type = GTK_MATCH_ALL_TAIL;
-  
-  if (strchr (pspec->pattern, '?'))
-    return;
-  
-  if (!strchr (pspec->pattern, '*'))
-    {
-      pspec->match_type = GTK_MATCH_EXACT;
-      return;
-    }
-  
-  p = pspec->pattern;
-  while (*p == '*')
-    p++;
-  if (p > pspec->pattern &&
-      !strchr (p, '*'))
-    {
-      gchar *t;
-      
-      pspec->match_type = GTK_MATCH_TAIL;
-      t = pspec->pattern;
-      pspec->pattern = g_strdup (p);
-      g_free (t);
-      g_free (pspec->pattern_reversed);
-      pspec->pattern_reversed = g_strdup (pspec->pattern);
-      g_strreverse (pspec->pattern_reversed);
-      pspec->pattern_length = strlen (pspec->pattern);
-      return;
-    }
-  
-  p = pspec->pattern_reversed;
-  while (*p == '*')
-    p++;
-  if (p > pspec->pattern_reversed &&
-      !strchr (p, '*'))
-    {
-      gchar *t;
-      
-      pspec->match_type = GTK_MATCH_HEAD;
-      t = pspec->pattern_reversed;
-      pspec->pattern_reversed = g_strdup (p);
-      g_free (t);
-      g_free (pspec->pattern);
-      pspec->pattern = g_strdup (pspec->pattern_reversed);
-      g_strreverse (pspec->pattern);
-      pspec->pattern_length = strlen (pspec->pattern);
-    }
-}
-
-gboolean
-gtk_pattern_match_string (GtkPatternSpec       *pspec,
-                         const gchar           *string)
-{
-  gchar *string_reversed;
-  guint length;
-  gboolean ergo;
-  
-  g_return_val_if_fail (pspec != NULL, FALSE);
-  g_return_val_if_fail (string != NULL, FALSE);
-  
-  length = strlen (string);
-  string_reversed = g_strdup (string);
-  g_strreverse (string_reversed);
-  
-  ergo = gtk_pattern_match (pspec, length, string, string_reversed);
-  g_free (string_reversed);
-  
-  return ergo;
-}
-
-gboolean
-gtk_pattern_match_simple (const gchar          *pattern,
-                         const gchar           *string)
-{
-  GtkPatternSpec pspec;
-  gboolean ergo;
-  
-  g_return_val_if_fail (pattern != NULL, FALSE);
-  g_return_val_if_fail (string != NULL, FALSE);
-  
-  gtk_pattern_spec_init (&pspec, pattern);
-  ergo = gtk_pattern_match_string (&pspec, string);
-  gtk_pattern_spec_free_segs (&pspec);
-  
-  return ergo;
-}
-
-void
-gtk_pattern_spec_free_segs (GtkPatternSpec     *pspec)
-{
-  g_return_if_fail (pspec != NULL);
-  
-  g_free (pspec->pattern);
-  pspec->pattern = NULL;
-  g_free (pspec->pattern_reversed);
-  pspec->pattern_reversed = NULL;
-}
-
 static guint
 gtk_binding_parse_signal (GScanner       *scanner,
                          GtkBindingSet  *binding_set,
@@ -1447,4 +1206,3 @@ gtk_binding_parse_binding (GScanner       *scanner)
 
   return G_TOKEN_NONE;
 }
-
index 051947d9d1340b2d2919e78d526f29ff5ea766a0..b5e6ed246a9da4c1fc3393dfd9755149e430bb2d 100644 (file)
@@ -41,33 +41,6 @@ extern "C" {
 #endif /* __cplusplus */
 
 
-/* Pattern matching
- */
-typedef struct _GtkPatternSpec GtkPatternSpec;
-
-struct _GtkPatternSpec
-{
-  GtkMatchType  match_type;
-  guint                 pattern_length;
-  gchar                *pattern;
-  gchar                *pattern_reversed;
-  gpointer      user_data;
-  guint                 seq_id;
-};
-
-void    gtk_pattern_spec_init      (GtkPatternSpec      *pspec,
-                                    const gchar         *pattern);
-void    gtk_pattern_spec_free_segs (GtkPatternSpec      *pspec);
-gboolean gtk_pattern_match         (GtkPatternSpec      *pspec,
-                                    guint                string_length,
-                                    const gchar         *string,
-                                    const gchar         *string_reversed);
-gboolean gtk_pattern_match_string   (GtkPatternSpec     *pspec,
-                                    const gchar         *string);
-gboolean gtk_pattern_match_simple   (const gchar        *pattern,
-                                    const gchar         *string);
-
-
 /* Binding sets
  */
 
index 5239421c3a39d610a33441b79730a6f22012290d..dc305332badaaccfcc0bbf7d718f181ea68c066b 100644 (file)
@@ -78,10 +78,10 @@ struct _GtkIFCBData
 };
 struct _GtkIFDumpData
 {
-  GtkPrintFunc          print_func;
-  gpointer              func_data;
-  guint                         modified_only : 1;
-  GtkPatternSpec       *pspec;
+  GtkPrintFunc  print_func;
+  gpointer      func_data;
+  guint                 modified_only : 1;
+  GPatternSpec *pspec;
 };
 
 
@@ -777,7 +777,7 @@ gtk_item_factory_foreach (gpointer hash_key,
   item = value;
   data = user_data;
 
-  if (data->pspec && !gtk_pattern_match_string (data->pspec, item->path))
+  if (data->pspec && !g_pattern_match_string (data->pspec, item->path))
     return;
 
   comment_prefix[0] = gtk_item_factory_class->cpair_comment_single[0];
@@ -800,7 +800,7 @@ gtk_item_factory_foreach (gpointer hash_key,
 }
 
 void
-gtk_item_factory_dump_items (GtkPatternSpec     *path_pspec,
+gtk_item_factory_dump_items (GPatternSpec       *path_pspec,
                             gboolean             modified_only,
                             GtkPrintFunc         print_func,
                             gpointer             func_data)
@@ -834,9 +834,9 @@ gtk_item_factory_print_func (gpointer     FILE_pointer,
 }
 
 void
-gtk_item_factory_dump_rc (const gchar            *file_name,
-                         GtkPatternSpec         *path_pspec,
-                         gboolean                modified_only)
+gtk_item_factory_dump_rc (const gchar  *file_name,
+                         GPatternSpec *path_pspec,
+                         gboolean      modified_only)
 {
   FILE *f_out;
 
@@ -1319,18 +1319,18 @@ void
 gtk_item_factory_create_menu_entries (guint              n_entries,
                                      GtkMenuEntry      *entries)
 {
-  static GtkPatternSpec pspec_separator = { 42, 0 };
-  static GtkPatternSpec pspec_check = { 42, 0 };
+  static GPatternSpec *pspec_separator = NULL;
+  static GPatternSpec *pspec_check = NULL;
   guint i;
 
   if (!n_entries)
     return;
   g_return_if_fail (entries != NULL);
 
-  if (pspec_separator.pattern_length == 0)
+  if (!pspec_separator)
     {
-      gtk_pattern_spec_init (&pspec_separator, "*<separator>*");
-      gtk_pattern_spec_init (&pspec_check, "*<check>*");
+      pspec_separator = g_pattern_spec_new ("*<separator>*");
+      pspec_check = g_pattern_spec_new ("*<check>*");
     }
 
   for (i = 0; i < n_entries; i++)
@@ -1359,9 +1359,9 @@ gtk_item_factory_create_menu_entries (guint              n_entries,
       entry.accelerator = entries[i].accelerator;
       entry.callback = entries[i].callback;
       entry.callback_action = 0;
-      if (gtk_pattern_match_string (&pspec_separator, path))
+      if (g_pattern_match_string (pspec_separator, path))
        entry.item_type = "<Separator>";
-      else if (!gtk_pattern_match_string (&pspec_check, path))
+      else if (!g_pattern_match_string (pspec_check, path))
        entry.item_type = NULL;
       else
        {
index bbe2febe6c9babfa221047e00002e44ba06feddf..536d4ea7bebdb052a14a5307f2ebfcffcda0f2e6 100644 (file)
@@ -32,7 +32,6 @@
 
 
 #include <gtk/gtkwidget.h>
-#include <gtk/gtkbindings.h>   /* for GtkPatternSpec */
 
 
 #ifdef __cplusplus
@@ -171,12 +170,12 @@ GtkWidget*        gtk_item_factory_get_item_by_action   (GtkItemFactory *ifactory,
  * all hash entries. otherwise only those entries will be dumped for which
  * the pattern matches, e.g. "<Image>*...".
  */
-void   gtk_item_factory_dump_items     (GtkPatternSpec         *path_pspec,
+void   gtk_item_factory_dump_items     (GPatternSpec           *path_pspec,
                                         gboolean                modified_only,
                                         GtkPrintFunc            print_func,
                                         gpointer                func_data);
 void   gtk_item_factory_dump_rc        (const gchar            *file_name,
-                                        GtkPatternSpec         *path_pspec,
+                                        GPatternSpec           *path_pspec,
                                         gboolean                modified_only);
 void   gtk_item_factory_print_func     (gpointer                FILE_pointer,
                                         const gchar            *string);
index 01c26c2fa299d1a733b2c05df85941965c14c16c..10544dc97eeb51c5be3939b65a39ecf82513fad2 100644 (file)
@@ -69,8 +69,8 @@ typedef struct _GtkRcFile   GtkRcFile;
 
 struct _GtkRcSet
 {
-  GtkPatternSpec pspec;
-  GtkRcStyle   *rc_style;
+  GPatternSpec *pspec;
+  GtkRcStyle   *rc_style;
 };
 
 struct _GtkRcFile
@@ -1064,7 +1064,7 @@ gtk_rc_free_rc_sets (GSList *slist)
       GtkRcSet *rc_set;
 
       rc_set = slist->data;
-      gtk_pattern_spec_free_segs (&rc_set->pspec);
+      g_pattern_spec_free (rc_set->pspec);
       g_free (rc_set);
 
       slist = slist->next;
@@ -1156,7 +1156,7 @@ gtk_rc_styles_match (GSList       *rc_styles,
       rc_set = sets->data;
       sets = sets->next;
 
-      if (gtk_pattern_match (&rc_set->pspec, path_length, path, path_reversed))
+      if (g_pattern_match (rc_set->pspec, path_length, path, path_reversed))
        rc_styles = g_slist_append (rc_styles, rc_set->rc_style);
     }
   
@@ -1254,7 +1254,7 @@ gtk_rc_add_rc_sets (GSList      *slist,
     new_style->bg_pixmap_name[i] = g_strdup (rc_style->bg_pixmap_name[i]);
   
   rc_set = g_new (GtkRcSet, 1);
-  gtk_pattern_spec_init (&rc_set->pspec, pattern);
+  rc_set->pspec = g_pattern_spec_new (pattern);
   rc_set->rc_style = rc_style;
   
   return g_slist_prepend (slist, rc_set);
@@ -3002,7 +3002,7 @@ gtk_rc_parse_path_pattern (GScanner   *scanner)
        }
 
       rc_set = g_new (GtkRcSet, 1);
-      gtk_pattern_spec_init (&rc_set->pspec, pattern);
+      rc_set->pspec = g_pattern_spec_new (pattern);
       rc_set->rc_style = rc_style;
 
       if (path_type == GTK_PATH_WIDGET)
index 0b4cbac2e7b8192e9ff33ded84bb8e9eb90e0c1f..e0b82820e113166c1c70a6695a532c108a4f3fca 100644 (file)
@@ -259,59 +259,89 @@ gtk_settings_notify (GObject    *object,
 #endif
 }
 
-static void
-apply_queued_setting (GtkSettings      *data,
-                     GParamSpec       *pspec,
-                     GtkSettingsValue *qvalue)
+gboolean
+_gtk_settings_parse_convert (GtkRcPropertyParser parser,
+                            const GValue       *src_value,
+                            GParamSpec         *pspec,
+                            GValue             *dest_value)
 {
-  gboolean warn_convert = TRUE;
+  gboolean success = FALSE;
 
-  if (g_value_type_transformable (G_VALUE_TYPE (&qvalue->value), G_PARAM_SPEC_VALUE_TYPE (pspec)))
-    {
-      GValue tmp_value = { 0, };
+  g_return_val_if_fail (G_VALUE_HOLDS (dest_value, G_PARAM_SPEC_VALUE_TYPE (pspec)), FALSE);
 
-      warn_convert = FALSE;
-      g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
-      if (g_param_value_convert (pspec, &qvalue->value, &tmp_value, TRUE))
-       g_object_set_property (G_OBJECT (data), pspec->name, &tmp_value);
+  if (parser)
+    {
+      GString *gstring;
+      gboolean free_gstring = TRUE;
+      
+      if (G_VALUE_HOLDS (src_value, G_TYPE_GSTRING))
+       {
+         gstring = g_value_get_boxed (src_value);
+         free_gstring = FALSE;
+       }
+      else if (G_VALUE_HOLDS_LONG (src_value))
+       {
+         gstring = g_string_new ("");
+         g_string_printfa (gstring, "%ld", g_value_get_long (src_value));
+       }
+      else if (G_VALUE_HOLDS_DOUBLE (src_value))
+       {
+         gstring = g_string_new ("");
+         g_string_printfa (gstring, "%f", g_value_get_double (src_value));
+       }
+      else if (G_VALUE_HOLDS_STRING (src_value))
+       {
+         gchar *tstr = g_strescape (g_value_get_string (src_value), NULL);
+         
+         gstring = g_string_new ("\"");
+         g_string_append (gstring, tstr);
+         g_string_append_c (gstring, '\"');
+         g_free (tstr);
+       }
       else
        {
-         gchar *debug = g_strdup_value_contents (&tmp_value);
-
-         g_message ("%s: rc-value `%s' for rc-property \"%s\" of type `%s' has invalid contents \"%s\"",
-                    qvalue->origin,
-                    G_VALUE_TYPE_NAME (&qvalue->value),
-                    pspec->name,
-                    g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
-                    debug);
-         g_free (debug);
+         g_return_val_if_fail (G_VALUE_HOLDS (src_value, G_TYPE_GSTRING), FALSE);
+         gstring = NULL; /* silence compiler */
        }
-      g_value_unset (&tmp_value);
+
+      success = (parser (pspec, gstring, dest_value) &&
+                !g_param_value_validate (pspec, dest_value));
+
+      if (free_gstring)
+       g_string_free (gstring, TRUE);
     }
+  else if (!G_VALUE_HOLDS (src_value, G_TYPE_GSTRING) &&
+          g_value_type_transformable (G_VALUE_TYPE (src_value), G_VALUE_TYPE (dest_value)))
+    success = g_param_value_convert (pspec, src_value, dest_value, TRUE);
+
+  return success;
+}
+
+static void
+apply_queued_setting (GtkSettings      *data,
+                     GParamSpec       *pspec,
+                     GtkSettingsValue *qvalue)
+{
+  GValue tmp_value = { 0, };
+  GtkRcPropertyParser parser = g_param_spec_get_qdata (pspec, quark_property_parser);
+
+  g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+  if (_gtk_settings_parse_convert (parser, &qvalue->value,
+                                  pspec, &tmp_value))
+    g_object_set_property (G_OBJECT (data), pspec->name, &tmp_value);
   else
     {
-      GtkRcPropertyParser parser = g_param_spec_get_qdata (pspec, quark_property_parser);
-
-      if (parser)
-       {
-         GValue tmp_value = { 0, };
-
-         g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
-         if (parser (pspec, g_value_get_boxed (&qvalue->value), &tmp_value))
-           {
-             warn_convert = FALSE;
-             g_object_set_property (G_OBJECT (data), pspec->name, &tmp_value);
-           }
-         g_value_unset (&tmp_value);
-       }
+      gchar *debug = g_strdup_value_contents (&tmp_value);
+      
+      g_message ("%s: failed to retrive property `%s' of type `%s' from rc file value \"%s\" of type `%s'",
+                qvalue->origin,
+                pspec->name,
+                g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
+                debug,
+                G_VALUE_TYPE_NAME (&tmp_value));
+      g_free (debug);
     }
-
-  if (warn_convert)
-    g_message ("%s: unable to convert rc-value of type `%s' to rc-property \"%s\" of type `%s'",
-              qvalue->origin,
-              G_VALUE_TYPE_NAME (&qvalue->value),
-              pspec->name,
-              g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
+  g_value_unset (&tmp_value);
 }
 
 static guint
@@ -379,7 +409,7 @@ settings_install_property_parser (GtkSettingsClass   *class,
 }
 
 GtkRcPropertyParser
-_gtk_rc_property_parser_for_type (GType type)
+_gtk_rc_property_parser_from_type (GType type)
 {
   if (type == GDK_TYPE_COLOR)
     return gtk_rc_property_parse_color;
@@ -404,7 +434,7 @@ gtk_settings_install_property (GtkSettings *settings,
   g_return_if_fail (GTK_IS_SETTINGS (settings));
   g_return_if_fail (G_IS_PARAM_SPEC (pspec));
 
-  parser = _gtk_rc_property_parser_for_type (G_PARAM_SPEC_VALUE_TYPE (pspec));
+  parser = _gtk_rc_property_parser_from_type (G_PARAM_SPEC_VALUE_TYPE (pspec));
 
   settings_install_property_parser (GTK_SETTINGS_GET_CLASS (settings), pspec, parser);
 }
index 6a861ad3223abc5863ab2f00bae6144814e449f0..59c2fd90cda444a700364bb4ba44773749995f03 100644 (file)
@@ -110,9 +110,15 @@ void               gtk_settings_set_double_property (GtkSettings   *settings,
                                                  gdouble        v_double,
                                                  const gchar   *origin);
 
-void            _gtk_settings_handle_event       (GdkEventSetting *event);
 
-GtkRcPropertyParser _gtk_rc_property_parser_for_type (GType type);
+/* implementation details */
+void                _gtk_settings_handle_event        (GdkEventSetting    *event);
+GtkRcPropertyParser _gtk_rc_property_parser_from_type (GType               type);
+gboolean           _gtk_settings_parse_convert       (GtkRcPropertyParser parser,
+                                                      const GValue       *src_value,
+                                                      GParamSpec         *pspec,
+                                                      GValue             *dest_value);
+
 
 #ifdef __cplusplus
 }
index 3b01a5614abdc6df390b66cf5edc9c122e084870..b749777020eff4f2b7710d03968060e104f21526 100644 (file)
@@ -32,6 +32,7 @@
 #include "gtkwidget.h"
 #include "gtkthemes.h"
 #include "gtkiconfactory.h"
+#include "gtksettings.h"       /* _gtk_settings_parse_convert() */
 
 #define LIGHTNESS_MULT  1.3
 #define DARKNESS_MULT   0.7
@@ -1244,6 +1245,7 @@ _gtk_style_peek_property_value (GtkStyle           *style,
     return &pcache->value;
 
   /* cache miss, initialize value type, then set contents */
+  g_param_spec_ref (pcache->pspec);
   g_value_init (&pcache->value, G_PARAM_SPEC_VALUE_TYPE (pspec));
 
   /* value provided by rc style? */
@@ -1264,55 +1266,25 @@ _gtk_style_peek_property_value (GtkStyle           *style,
     }
 
   /* when supplied by rc style, we need to convert */
-  if (rcprop)
+  if (rcprop && !_gtk_settings_parse_convert (parser, &rcprop->value,
+                                             pspec, &pcache->value))
     {
-      if (G_VALUE_TYPE (&rcprop->value) == G_TYPE_GSTRING)
-       {
-         GString *gstring;
-         
-         /* value still unparsed, need to revert to user supplied parser function */
-         
-         gstring = g_value_get_boxed (&rcprop->value);
-         
-         if (!parser || !parser (pspec, gstring, &pcache->value) ||
-             g_param_value_validate (pspec, &pcache->value))
-           {
-             gchar *contents = g_strescape (gstring->str, NULL);
-
-             g_message ("%s: failed to parse property `%s::%s' of type `%s' from rc file value \"%s\"",
-                        rcprop->origin,
-                        g_type_name (pspec->owner_type), pspec->name,
-                        g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
-                        gstring->str);
-             g_free (contents);
-             rcprop = NULL;
-           }
-       }
-      else
-       {
-         /* we use the normal conversion functionality of param specs */
-         if (!g_param_value_convert (pspec, &rcprop->value, &pcache->value, TRUE))
-           {
-             gchar *contents = g_strdup_value_contents (&rcprop->value);
-             
-             g_message ("%s: failed to retrive property `%s::%s' of type `%s' from rc file value \"%s\" of type `%s'",
-                        rcprop->origin,
-                        g_type_name (pspec->owner_type), pspec->name,
-                        g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
-                        contents,
-                        G_VALUE_TYPE_NAME (&rcprop->value));
-             g_free (contents);
-             rcprop = NULL;
-           }
-       }
+      gchar *contents = g_strdup_value_contents (&rcprop->value);
+      
+      g_message ("%s: failed to retrive property `%s::%s' of type `%s' from rc file value \"%s\" of type `%s'",
+                rcprop->origin,
+                g_type_name (pspec->owner_type), pspec->name,
+                g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
+                contents,
+                G_VALUE_TYPE_NAME (&rcprop->value));
+      g_free (contents);
+      rcprop = NULL; /* needs default */
     }
   
   /* not supplied by rc style (or conversion failed), revert to default */
   if (!rcprop)
     g_param_value_set_default (pspec, &pcache->value);
 
-  g_param_spec_ref (pcache->pspec);
-
   return &pcache->value;
 }
 
@@ -4025,7 +3997,9 @@ gtk_default_draw_resize_grip (GtkStyle       *style,
           }
       }
       break;
-
+    default:
+      g_assert_not_reached ();
+      break;
     }
   
   if (area)
index 84d8db22296311488c77c421180fe5b73d5453eb..3a63ace0f34743b2f2568313f85bd9b2f0690b14 100644 (file)
@@ -5411,7 +5411,7 @@ gtk_widget_class_install_style_property (GtkWidgetClass *class,
   g_return_if_fail (GTK_IS_WIDGET_CLASS (class));
   g_return_if_fail (G_IS_PARAM_SPEC (pspec));
 
-  parser = _gtk_rc_property_parser_for_type (G_PARAM_SPEC_VALUE_TYPE (pspec));
+  parser = _gtk_rc_property_parser_from_type (G_PARAM_SPEC_VALUE_TYPE (pspec));
 
   gtk_widget_class_install_style_property_parser (class, pspec, parser);
 }
index 2772f4069133098dc350954238b42b2dd3948a00..408cd54a6526720de44eb77199bf47d43c125e3c 100644 (file)
@@ -32,7 +32,7 @@ style "global-style-properties"
 {
 #  xthickness = 20
   GtkSpinButton::shadow_type = etched-out
-  GtkEntry::cursor_color = { 1.0, 0.0, 0.0 }
+  GtkEntry::cursor_color = "#ff00ff"
 }
 class "GtkWidget" style "global-style-properties"
 
index 2772f4069133098dc350954238b42b2dd3948a00..408cd54a6526720de44eb77199bf47d43c125e3c 100644 (file)
@@ -32,7 +32,7 @@ style "global-style-properties"
 {
 #  xthickness = 20
   GtkSpinButton::shadow_type = etched-out
-  GtkEntry::cursor_color = { 1.0, 0.0, 0.0 }
+  GtkEntry::cursor_color = "#ff00ff"
 }
 class "GtkWidget" style "global-style-properties"